// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-12

package kind

// ReturnMode
// 回鱼模式.
type ReturnMode int

const (
	ReturnModeWeight ReturnMode = 1
	ReturnModeCount  ReturnMode = 2
	ReturnModeNot    ReturnMode = 9
)

var (
	returnModeTexts = map[ReturnMode]string{
		ReturnModeWeight: "按重量回鱼",
		ReturnModeCount:  "按条数回鱼",
		ReturnModeNot:    "不回鱼",
	}
	returnModeUndefined = ""

	returnModeFlags = map[ReturnMode]string{
		ReturnModeWeight: "bw",  // By Weight
		ReturnModeCount:  "bc",  // By Count
		ReturnModeNot:    "not", // Not
	}
	returnModeUnknownFlag = ""
)

func ReturnModeDict() []map[string]any {
	var res = make([]map[string]any, 0)
	for _, v := range []ReturnMode{
		ReturnModeWeight,
		ReturnModeCount,
		ReturnModeNot,
	} {
		res = append(res, map[string]any{
			"Key":   v,
			"Value": v.Text(),
		})
	}
	return res
}

func (o ReturnMode) Flag() string {
	if str, ok := returnModeFlags[o]; ok {
		return str
	}
	return returnModeUnknownFlag
}

func (o ReturnMode) IsCount() bool  { return o == ReturnModeCount }
func (o ReturnMode) IsWeight() bool { return o == ReturnModeWeight }
func (o ReturnMode) IsNot() bool    { return o == ReturnModeNot }

func (o ReturnMode) Text() string {
	if str, ok := returnModeTexts[o]; ok {
		return str
	}
	return returnModeUndefined
}
